CXXFLAGS  =-O0 -g -Wall -I../include -fPIC
CFLAGS    =-O0 -g -Wall -std=c99 -pedantic -I../include -fPIC

CODEGEN_DIR = ../../codegen
CODEGEN     = $(CODEGEN_DIR)/codegen.pl -I$(CODEGEN_DIR)

CLASSES= \
	message host module \
	data_reader data_writer data_input data_output \
	sound_reader sound_writer sound_input sound_output \
	decoder dsp encoder playlist filesystem database

OBJECTS = \
	rc.o value.o basic_message.o \
	$(foreach CLASS, $(CLASSES), $(CLASS)_ptr.o $(CLASS)_api.o)

ARTIFACTS   = stream_api.c $(OBJECTS)
OUT         = libbamp.a

.PHONY: all install clean headers

all: headers $(OBJECTS)
	ar -rcs $(OUT) $(OBJECTS)

headers:
	make -C../include/bamp

install:

%_api.c: api.tmpl.c
	$(CODEGEN) -D "CLASSNAME=bamp::$*" -i api.tmpl.c -o $@

%_ptr.cpp: wrap.tmpl.cpp
	$(CODEGEN) -D "CLASSNAME=bamp::$*" -i wrap.tmpl.cpp -o $@

clean:
	rm -f $(ARTIFACTS) $(OUT)
